package com.get.backstage.user.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.get.backstage.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 用户信息表
 * @TableName user
 */
@TableName(value ="user")
@Data
@ApiModel(value = "用户类")
public class User extends BaseEntity implements Serializable, UserDetails {
    /**
     * 主键
     */
    @ApiModelProperty(value = "主键Id")
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 用户的编号
     */
    @ApiModelProperty(value = "用户的编号")
    private String userCode;



    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名")
    private String username;

    /**
     * 密码
     */
    @ApiModelProperty(value = "密码")
    private String password;

    /**
     * 邮箱
     */
    @ApiModelProperty(value = "邮箱")
    private String email;

    /**
     * 手机号
     */
    @ApiModelProperty(value = "手机号")
    private String phone;

    /**
     * 用户类型：0为普通用户,1为vip用户
     */
    @ApiModelProperty(value = "用户类型：0为普通用户,1为vip用户")
    private Byte userType;

    /**
     * 角色id集合例如（1，2）
     */
    @ApiModelProperty(value = "用户类型：0为普通用户,1为vip用户")
    private String roleCodes;


    /**
     * 角色id集合例如（1，2）
     */
    @ApiModelProperty(value = "审批类型, induction1为第一审批人,induction2为入职第二审批人")
    private String approvalType;









    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    /*@Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }*/

    @TableField(exist = false)
    @JsonIgnore
    private List<GrantedAuthority> authorities;

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}